<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta charset="UTF-8">
<title>资源管理</title> $!{include("import_js_css.html")}
<link rel="stylesheet" type="text/css"
	href="${viewPath}/resources/css/basic.css" />
</head>
<body>
	$!{include("header.html")}
	<div class="container menu_all">
		<div class="tabbable tabs-left" id="div_ul_tab">
			$!{include("basic_tab.html")}
			<div class="tab-content">
				<!-- 查询条件 -->
				<div class="tab-pane active" id="panel-task">
					<form class="form-horizontal" role="form" name="authorityForm"
						action="yueyogaAdmin/findAllResources.jhtml" method="post">
						<div class="form-group">
							<div class="panel-basic-search">
								<label for="txtUserName" class="col-sm-1 control-label">名称</label>
								<div class="col-sm-3">
									<input type="text" class="form-control" name="name"
										id="txtUserName" value="${name}">
								</div>
								<label for="enabled" class="col-sm-1 control-label">状态</label>
								<div class="col-sm-3">
									<select class="selectpicker" data-width="100%" id="enabled"
										name="enabled">
										<!-- #if(enabled == 1) -->
											<option value="1" selected>启用</option>
										<!-- #else -->
											<option value="1">启用</option>
										<!-- #end -->
										
										<!-- #if(enabled == 0) -->
											<option value="0" selected>禁用</option>
										<!-- #else -->
											<option value="0">禁用</option>
										<!-- #end -->
									</select>
								</div>

								<br /> <br /> <input type="hidden" name="pageNo"
									id="hidPageNo" />
								<div class="panel-btn-basic">
									<button type="submit" class="btn-ade-default2">搜索</button>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
			<!-- 查询结果 -->
			<div class="div_search_result">
				<div class="panel-heading panel-result-title">
					<h3 class="panel-title">查询结果</h3>
					<div class="btn-group btn-group-sm btn-gp-default">
						<button id="btn_add" type="button"
							class="btn btn-default panel-radius-left">添加</button>
						<button id="btn_delete" type="button"
							class="btn btn-default panel-radius-right">删除</button>
					</div>
				</div>

				<table class="table table-bordered table-hover table-condensed tb"
					style="text-align: center; border-bottom: 1px solid #DDDDDD;">
					<tr>
						<td width="100"><input id="chkallIds" type="checkbox" /></td>
						<td width="100">编号</td>
						<td width="290">名称</td>
						<td width="290">路径</td>
						<td width="290">描述</td>
						<td width="100">状态</td>
					<tr>
						<!--#set(PaginatedList<Resource> resources)  -->
						<!--#for(Resource resource : resources)-->
					<tr>
						<td><input name="chk_name" type="checkbox"
							value="${resource.id}" /></td>
						<td>${resource.id}</td>
						<td>${resource.name}</td>
						<td>${resource.url}</td>
						<td>${resource.description}</td>
						<td>${resource.enabled==true?'启用':'禁用'}</td>
					</tr>
					<!--#end-->
				</table>
				<div class="div_page main_div_page">
					<!--
					#set(
						pager = resources.pager,
						totalResults = pager.getCountOfTotalResults(),
						totalPages = pager.getCountOfTotalPages() * 1,
						pageSize = pager.pageSize,
						pageNo = pager.pageNo,
						prePageNo = pager.getPrevPageNo(),
						nextPageNo = pager.getNextPageNo()
					)
				-->
					<!-- 列表分页 -->
					<div class="paging-page">$!{include("paging_page.html")}</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		//去掉下拉输入框
		$("#enabled").select2({
			width: "100%",
			minimumResultsForSearch: -1
		});
		
		var enabled = '${enabled}';
		$("#enabled").select2("val", enabled);
		$("#chkallIds").click(function() {
			$(this).prop("checked", $(this).prop("checked"));
			$("input[name=chk_name]").prop("checked", $(this).prop("checked"));
		});
		$("#btn_add").click(function() {
			window.location.href = "yueyogaAdmin/toAddResource.jhtml";
		});
		$("#btn_delete").click(function() {
			var arr = new Array();
			$("input[name=chk_name]:checked").each(function() {
				arr.push($(this).val());
			});
			if (arr.length > 0) {
				confirm('确定要删除吗？', function() {
					var url = "yueyogaAdmin/deleteResource.jhtml?ids="
							+ arr;
					$.post(url, function(resp) {
						var data = eval('(' + resp + ')');
						if (data.success) {
							var d = alert(data.msg);
							setTimeout(function() {
								d.close().remove();
								$("input[name=chk_name]").prop(
										"checked", false);
							}, 1000);
							$("form[name=authorityForm]").submit();
						} else {
							error(data.msg);
						}
					});
				});
			} else {
				alert("请选择您要删除的记录!");
			}
		});
	});

	function changePage(value) {
		value = value * 1;
		var totalPages = '${totalPages}';
		if (value > totalPages) {
			value = totalPages;
		} else if (value < 1) {
			value = 1;
		}
		$("#txtPageNumber").val(value);
		goToPage(value);
	}
	function goToPage(pageNo) {
		$("#hidPageNo").val(pageNo);
		document.authorityForm.submit();
	}
</script>
</html>